package cars;

import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: mac
 * Date: 2022-11-24
 * Time: 12:06
 */
//BusList存储客车
public class BusList extends VehicleList{

    LinkedList<Bus> list;
    public BusList(){
        list = new LinkedList<>();
        list.add(new Bus("京6566754","金杯","16座",800));
        list.add(new Bus("京8696997","金杯","32座",800));
        list.add(new Bus("京9696996","金龙","16座",1500));
        list.add(new Bus("京8696998","金龙","32座",1500));
    }
    public void printf(String velName){
        int number = 1;
        for (int i = 0; i < list.size(); i++) {
            if (list.get(i).brand.compareTo(velName) == 0){
                System.out.print(number + "." + list.get(i).type + "   ");
                number++;
            }
        }
        System.out.println();
    }
    public Bus find(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Bus bus = list.get(i);
            if (bus.brand.compareTo(data1) == 0 && bus.type.compareTo(data2) == 0){
                System.out.println(bus.vehicleld);
                return bus;
            }
        }
        return null;
    }
    public double getPerRent(Vehicle bus, int days){
        if (days >= 3 && days <= 7){
            return bus.perRent * days * 0.9;
        }else if (days >= 7 && days <= 30){
            return bus.perRent * days * 0.8;
        }else if (days >= 30 && days <= 150){
            return bus.perRent * days * 0.7;
        }else if (days >= 150){
            return bus.perRent * days * 0.6;
        }else{
            return bus.perRent * days;
        }
    }
    public int del(String data1, String data2){
        for (int i = 0; i < list.size(); i++) {
            Bus vehicle = list.get(i);
            if (vehicle.brand.compareTo(data1) == 0 && vehicle.type.compareTo(data2) == 0){
                return i;
            }
        }
        return -1;
    }
}
